import app


class RechargeApi:

    def __init__(self, session):
        # 接收session对象的变量
        self.session = session
        self.url_recharge_verify_code = app.BASE_HOST + "/common/public/verifycode/{}"
        self.url_recharge = app.BASE_HOST + "/trust/trust/recharge"

    # 获取充值验证码接口
    def get_recharge_verify_code(self,r):
        return self.session.get(url=self.url_recharge_verify_code.format(r))


    # 充值接口
    def recharge(self,amount,valicode): #动态变化已参数形式进行传递
        # 定义一个字典变量，用来接收请求体数据
        data_dict ={"paymentType":"chinapnrTrust","amount":amount,"formStr":"reForm","valicode":valicode}
        return self.session.post(url= self.url_recharge,data=data_dict)


    # 第三方充值接口
    def third_recharge(self,url,data_dict):
        return self.session.post(url =url,data=data_dict)

